from tests.pytests.helpers.codegen_helpers import compile_chunk, assert_code_contains


def test_free_function():
    def add(a: int, b: int) -> int:
        c = a + b
        return c

    block = compile_chunk(add)
    assert_code_contains(
        block,
        """
        int add(int a, int b) {
            int c = a + b;
            return c;
        }
        """,
    )


def test_add():
    def add(a: int, b: int) -> int:
        c = a + b
        return c

    block = compile_chunk(add)
    assert_code_contains(
        block,
        """
        int add(int a, int b) {
            int c = a + b;
            return c;
        }
        """,
    )
